@extends('user.layouts.head')
@section('content')
    <body>
    <div id="app">
        <div class="wrapper -header-fixed">

        @include('user.layouts.navbar')
        @include('user.layouts.sidebar')

        <!-- 内容页开始-->
            <div class="content-container">
                <div class="container-fluid">
                    <div class="page-content">

                        <nav aria-label="breadcrumb">
                            <ol class="breadcrumb">
                                <li class="breadcrumb-item"><a href="{{ route('dashboard') }}">仪表盘</a></li>
                                <li class="breadcrumb-item active" aria-current="page">获取链接</li>
                            </ol>
                        </nav>

                        <div class="card">
                            <div class="card-body">

                                <div class="form-group">
                                    <div class="row">
                                        <div class="col-lg-10 col-md-7" style="margin-bottom: 10px">
                                        <!-- <a href="{{route('promotion.create')}}" class="btn btn-primary"> 添加 </a> -->
                                        </div>
                                        <div class="col-lg-2 col-md-5">
                                            <div class="input-group">
                                                <input type="text" class="form-control" id="search" placeholder="搜索...">
                                                <button class="btn btn-primary"
                                                        onclick="window.location.href = '{{ route('income.index') }}?search='+$('#search').val()">
                                                    搜索
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="table-responsive">
                                    <table class="table table-sm table-hover text-center">
                                        <thead>
                                        <tr>
                                            <th style="min-width:50px;">ID</th>
                                            <th style="min-width:520px;">正在推广的链接</th>
                                            <th style="min-width:80px;">单价 /次</th>
                                            <th style="min-width:150px;">剩余额度</th>
                                            <th style="min-width:100px;">开始时间</th>
                                            <th style="min-width:100px;">结束时间</th>
                                            <th style="min-width:99px;">操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        @foreach($promotion as $key => $data)
                                            <tr>
                                                <td>{{($promotion->currentPage()-1)*16+1+$key}}</td>
                                                <td id="url_{{$data->id}}">http://{{ $_SERVER['SERVER_NAME'] }}/user/income/url?id={{ Auth::id() }}&code={{$data->code}}</td>
                                                <td>{{$data->single}}</td>
                                                <td>{{$data->total}}</td>
                                                <td>{{$data->start_date}}</td>
                                                <td>{{$data->end_date}}</td>
                                                <td>
                                                    <button type="button" class="btn btn-primary btn-sm" data-clipboard-target="#url_{{$data->id}}">复制链接 </button>
                                                </td>
                                            </tr>
                                        @endforeach
                                        </tbody>
                                    </table>
                                </div>

                            </div> <!-- .card-body -->

                            <!-- 分页 -->
                            <nav class="page-card-pagination">
                                <ul class="pagination justify-content-center">
                                    {{$promotion->Links()}}
                                </ul>
                            </nav>
                            <!-- end分页 -->

                        </div> <!-- .card -->

                    </div> <!-- page-content -->
                </div> <!-- .container-fluid -->
            </div> <!-- .content-container -->
        </div> <!-- .wrapper -->
    </div> <!-- #app -->
    <script src="{{ mix('js/app.js') }}"></script>
    <script src="{{ asset('/js/main.js') }}"></script>
    <script>
        //复制
        var clipboard = new ClipboardJS('.btn');
        clipboard.on('success', function (e) {
            e.clearSelection();
            toast('复制成功，粘贴（Ctrl+V）给您的朋友就能获得收入了。');
        });
    </script>
    </body>

@endsection
